home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / WINPROGS / INTWHLP1.ZIP / INTWHLP.PAS < prev    next >
Pascal/Delphi Source File  |  1994-02-16  |  20KB  |  697 lines

  1. (*
  2.   Interrupt List -> WinHelp converter V1.01 (c) 1994 by Christian Müller-Planitz
  3.   -----------------------------------------------------------------------------
  4.   Author: cmuelle@eos.ncsu.edu,  cmueller@techfak.uni-bielefeld.de
  5.  
  6.  
  7.   The source and the compiled EXE-file can be freely distributed as long as
  8.   no changes are made without my knowledge.
  9.  
  10.   --------------------------------
  11.   Notes:
  12.    The program was tested with INTLIST38 and INTLIST39 and its output
  13.      was successfully compiled with the MS-Help-compiler "HC31.EXE" V3.10.445.
  14.  
  15.    The program needs the file "INTWHLP.DAT" in the 'source' directory.
  16.  
  17.    The program converted all sourcefiles (INTERRUP.* and *.LST) to
  18.      13 RTF files which needed 11MB on my harddrive.
  19.  
  20.    Compiling the RTF-files without compression took 13 minutes in
  21.      a DOS-Window under Win/NT on a 486-50 (if you run it under DOS
  22.      and if you have a fast hardrive cache, it might be faster).
  23.  
  24.    The (uncompressed) compiled HLP-File was approximately 7MB large.
  25.    If you want to create a compressed HLP-file, you have to exchange the
  26.      comments in the generated help-project file ("RB.HPJ"). Compressing
  27.      reduces the size of the HLP-file to 3MB but it takes
  28.      *more* (?? 28MB ??)  space on your harddrive while compiling.
  29.      In order to speed up compiling the compressed file, I've included a
  30.      temporary file ("RB.PH") of the helpcompiler in this archive.
  31.      Copy this file into the directory containing all the RTF files
  32.      before starting the compiler. This file is specific for INTERLIST39, so
  33.      if you want to get maximal compression in future versions, remove it.
  34.  
  35.    After the compilation finishes, you will find the file "RB.HLP".
  36.      Start Windows, create an icon in the program manager and double-click on it.
  37.  
  38.  
  39.   --------------------------------
  40.  
  41.    If you find this program usefull, if it does not work or if you have ideas
  42.    how to expand its functionality, feel fee to write an e-mail to me.
  43.  
  44.    As usual, I do not take any responsibility for possible damages done by
  45.    this program.
  46.  
  47.  
  48.   Two questions and their answers :
  49.   ---------------------------------
  50.    WHY is the HLP-file so large ?
  51.      In contrast to other programs that convert the interrupt list to
  52.      DOS-based hypertext systems, this program generates a large
  53.      index file that allows you to search for keywords.
  54.  
  55.    WHY did I wrote this program in Pascal and not in C ?
  56.      I think Pascal is a pretty nice language for small projects.
  57.      Another reason is the availability of efficient string handling under Pascal.
  58. *)
  59.  
  60.  {$A+,B-,D-,E-,F-,G+,I+,L-,N-,O-,P-,Q-,R-,S-,T-,V+,X+,Y+}
  61.  
  62.  
  63. {$DEFINE ProcessIntList}
  64. {$DEFINE ProcessPorts}
  65. {$DEFINE ProcessMemory}
  66. {$DEFINE ProcessBugs}
  67. {$DEFINE ProcessCMOS}
  68.  
  69.  
  70.  
  71. Program RB2HLP;
  72.   CONST InPath  : String = 'd:\tmp\';
  73.         OutPath : String = 'd:\tmp\out\';
  74.   CONST IncludeFile      = 'INTWHLP.DAT';
  75.  
  76.   Var OutFileCounter : Word;
  77.       IndexFile      : Text;                    { stores *all* section names }
  78.       IntFile        : Text;                    { stores one entry per int-number }
  79.       SubIntFile     : Text;                    { stores all subfunctions of an int per page }
  80.       HPJ            : Text;                    { hlep compiler project file }
  81.       TopicNo        : Word;
  82.       LastSection    : String;                  { stores number of last processed int }
  83.       IntTopicStr   : String;                   { stores handle to page with subfunctions of the int's}
  84.  
  85.   Const InvalidClassification = '-';
  86.  
  87.  
  88.   procedure CreateHPJ;
  89.     begin
  90.       assign(HPJ, OutPath + 'RB.HPJ');
  91.       rewrite(HPJ);
  92.       writeln(HPJ, '[OPTIONS]'#10'CONTENTS=CONTENTS'#10'COMPRESS=NO'#10';COMPRESS=YES'#10);
  93.       writeln(HPJ, '[CONFIG]'#10'BrowseButtons()'#10);
  94.       writeln(HPJ, '[FILES]'#10'index.rtf');
  95.      {$IFDEF ProcessIntList}
  96.       writeln(HPJ, 'int.rtf'#10'subint.rtf');
  97.      {$ENDIF}
  98.     end;
  99.  
  100.  
  101.  
  102.  
  103.  
  104.   Procedure NewHlpPage(VAR F : Text; S, ID : String; Classification : Char);
  105.     VAR q : Word;
  106.         BrowseID : STring;
  107.  
  108.     Procedure FootNote(Note: Char; ID : String);
  109.       begin
  110.         writeln(F, '{\up6 ',Note,'{\footnote \pard\plain \s2\f0\fs20\cf0\qj\lotusoutlinelevel0');
  111.         writeln(F, '{\up6 ',Note,'}{\field{\*\fldinst SYMBOL 16 \\f "" \\s 10 \\h}}', ID, '}}');
  112.       end;
  113.  
  114.  
  115.     Procedure StoreKeyWords(SS: String);
  116.       VAR p : Word;
  117.  
  118.        begin
  119.           repeat
  120.             p := POS(' - ', ss);
  121.             if p <> 0 then
  122.               begin
  123.                 ss[p+1] := ' ';
  124.                 ss[p+2] := ';';
  125.               end;
  126.           until p=0;
  127.  
  128.           FootNote('K', SS);
  129.        end;
  130.  
  131.  
  132.     begin
  133.       BrowseID := ID;
  134.       while Length(BrowseID) < 6 do
  135.         insert('0', BrowseID, 1);
  136.  
  137.       write(F, '\page ');
  138.       FootNote('#', ID);
  139.       FootNote('$', S);
  140.       FootNote('+', BrowseID);
  141.       if (Classification = InvalidClassification)
  142.         then StoreKeyWords(s)
  143.         else StoreKeyWords(Classification + ';' + s);
  144.  
  145.       writeln(F, '\pard\plain \s3\f0\fs28\cf1\b\sb144\sa72\lotusoutlinelevel1\keep\keepn {\up6 ', S, '}');
  146.  
  147.  
  148.       writeln(F, '\par \pard\plain \s4\f1\fs20\cf1\lotusoutlinelevel0 \tx855\tx1710\tx2565\tx3420\tx4275' +
  149.                  '\tx5130\tx5985\tx6840\tx7695');
  150.  
  151.  
  152.  
  153.     end;
  154.  
  155.  
  156.  
  157.   Procedure Out(VAR F: Text; S : String);
  158.     begin
  159.       write(F, S);
  160.     end;
  161.  
  162.  
  163. {Note: The table is not complete. But for it is sufficient for this purpose * }
  164.  
  165.   Function OEMtoANSI(q: Byte) : Byte;
  166.     Const Tab : Array[0..127]  of Byte =
  167.     ( 199,252,233,226,228,224,225,231,234,235,232,239,238,236,196,197,
  168.       201,230,198,244,246,242,251,249,253,214,220,162,163,165,182,131,
  169.       128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
  170.       128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
  171.       128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
  172.       128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
  173.       128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
  174.       128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128);
  175.  
  176.     begin
  177.       if q < 128
  178.         then OEMtoANSI := q
  179.         else OEMtoANSI := Tab[q-128];
  180.     end;
  181.  
  182.  
  183.  
  184.   Function HEX(b:byte):string;
  185.     Const h : array [0..15] of char = ('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
  186.     begin
  187.       Hex := h[b shr 4]+h[b and 15];
  188.     end;
  189.  
  190.  
  191.   Procedure ReadLine(VAR F: Text; VAR S: String);
  192.     VAR q: Word;
  193.         c: Byte;
  194.  
  195.     begin
  196.       readln(F, S);
  197.  
  198.       q:= 1;
  199.       while q <= Length(s) do    { duplicate all '\' }
  200.         begin
  201.           if s[q] = '\' then
  202.             begin
  203.               insert('\', s, q);
  204.               Inc(q);
  205.             end;
  206.           Inc(q);
  207.         end;
  208.  
  209.       q:= 1;
  210.       while q <= Length(s) do
  211.         begin
  212.           c := ord(s[q]);
  213.           if c = 9 then
  214.             begin
  215.               s[q] := '\';
  216.               insert('tab ', s, q+1);
  217.               Inc(q, 4);
  218.             end;
  219.  
  220.           if c >= 128 then   { escape all 'Umlaute' }
  221.             begin
  222.               insert(#39+HEX( OEMtoANSI(ord(s[q])) ), s, q+1);
  223.               s[q] := '\';
  224.               Inc(q,2);
  225.             end;
  226.           Inc(q);
  227.         end;
  228.  
  229.     end;
  230.  
  231.  
  232.  
  233.   Procedure OutLN(VAR F: Text; S : String);
  234.     begin
  235.       write(F, '\par ');
  236.       Out(F, S);
  237.       writeln(F);
  238.     end;
  239.  
  240.  
  241.   Procedure AddTopic(VAR F: Text; S, ID : String);
  242.     begin
  243.       write(F, '\par {\uldb ');
  244.       Out(F, s);
  245.       write(F, '}{\v ');
  246.       Out(F, ID);
  247.       writeln(F, '}');
  248.     end;
  249.  
  250.  
  251.  
  252.   Procedure CopyHeader(VAR F: Text);
  253.     VAR F3 : Text;
  254.         c  : Char;
  255.  
  256.     begin
  257.      {$I-}
  258.       assign(F3, InPath + 'INTWHLP.DAT');
  259.       reset(F3);
  260.      {$I+}
  261.       if IOResult <> 0 then
  262.         begin
  263.           writeln('Error opening ', InPath + IncludeFile);
  264.           HALT;
  265.         end;
  266.  
  267.     { this is certainly slow, but simple }
  268.       while not EOF(F3) do
  269.         begin
  270.           read(F3, c);
  271.           wr